package leetcode.D400.T370;

/**
 * @File Info: leetcode -- <Solution>
 * @Author: 18362
 * @Create: 2022-02-17 12:50:23 星期四
 */

class Solution {
    public int[] getModifiedArray(int length, int[][] updates) {
        int[] diff = new int[length];
        for (int i = 0; i < updates.length; i++) {
            diff[updates[i][0]] += updates[i][2];
            if (updates[i][1] + 1 < length) {
                diff[updates[i][1]+1] -= updates[i][2];
            }
        }
        for (int i = 1; i < length; i++) {
            diff[i] = diff[i-1] + diff[i];
        }
        return diff;
    }
}
